package com.dooioo.fangyou.web;

import com.dooioo.fangyou.entity.PetType;
import com.dooioo.fangyou.service.PetTypeService;

import java.beans.PropertyEditorSupport;

/**
 * com.dooioo.fangyou.web
 * User: kqy
 * Date: 2010-12-3
 * Time: 11:45:03
 */
public class PetTypeEditor extends PropertyEditorSupport {
    private PetTypeService petTypeService;

	public PetTypeEditor(PetTypeService petTypeService) {
		this.petTypeService = petTypeService;
	}

    @Override
	public void setAsText(String text) throws IllegalArgumentException {
		for (Object obj : this.petTypeService.queryForList()) {
            PetType type = (PetType)obj;
			if (type.getName().equals(text)) {
				setValue(type);
			}
		}
	}
}
